package com.neuedu.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.neuedu.dao.AdminDao;
import com.neuedu.model.Admin;

//把dao接口实现类，交给spring进行管理
@Repository
public class AdminDaoImpl implements AdminDao {

	// 代码层级的整合spring+mybatis
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	@Override
	public int countAdmin() {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.getMapper(AdminDao.class).countAdmin();
	}

	@Override
	public List<Admin> findAll(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.getMapper(AdminDao.class).findAll(map);
	}

	@Override
	public int addAdmin(Admin u) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.getMapper(AdminDao.class).addAdmin(u);
	}

	@Override
	public int updateAdmin(Admin u) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.getMapper(AdminDao.class).updateAdmin(u);
	}

	@Override
	public int deleteAdmin(int id) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.getMapper(AdminDao.class).deleteAdmin(id);
	}
	@Override
	public Admin findAdminByName(Admin u) {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.getMapper(AdminDao.class).findAdminByName(u);
	}
	

}
